package com.yanmushi.ms.client.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.cache.annotation.CacheKey;
import com.netflix.hystrix.contrib.javanica.cache.annotation.CacheResult;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Author yinlei
 * @Date 2018/3/27
 * @Desc todo
 */
@FeignClient(name = "ms.service", fallback = HelloServiceFallback.class)
@Primary
public interface HelloService {

    @GetMapping("/")
    String index();

    @GetMapping("/hello")
    String hello();

    @HystrixCommand
    @CacheResult
    @GetMapping("/query")
    String query(
            @RequestParam("id")
            @CacheKey Integer id);
}
